﻿@model GenerateDataModel
@{
    ViewBag.Title = "Everybody was GenFu Fighting";
}

<div class="jumbotron">
    <div class="pull-right col-lg-3">
        <img src="~/content/ninja.png" height="200" width="200" />
    </div>
    <h2>GenFu Your Objects</h2>

    <p class="lead">
        GenFu is a test and prototype data generation library targeting .NET Framework and .NET Core.
        It understands different topics - such as "contact details" or "blog posts" and uses that understanding to populate commonly named properties using reflection and an internal database of values or randomly created data.
    </p>
    <div class="">
        <a href="#installation" class="btn btn-primary btn-lg"><span class="fa fa-arrow-circle-down"></span> Installation</a>
        <a href="#try_it_out" class="btn btn-primary btn-lg"><span class="fa fa-arrow-circle-down"></span> Try it out!</a>
        <a href="/wireframe" class="btn btn-primary btn-lg"><span class="fa fa-puzzle-piece"></span> Prototype</a>
    </div>
</div>

<span id="try_it_out"></span>
<div class="row" >
    <div class="col-lg-12 col-md-12 col-sm-12">
        <h2>Try GenFu Out</h2>
        <form class="form-horizontal" method="post">
            <div class="form-group">
                <div class="col-lg-9 col-md-9 col-sm-9">
                    <textarea id="Source" name="Source" class="form-control" rows="12">@Model.Source</textarea>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-3">
                    <button class="btn btn-success btn-lg" type="submit"><span class="glyphicon glyphicon-play"></span> Generate test data</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="row">
    @if (Model.HasCompileErrors)
    {
        <div class="panel panel-danger">
            <div class="panel-heading">Compilation Error</div>
            <div class="panel-body">
                @foreach (var error in Model.CompileErrors)
                {
                    <p>@error</p>
                }
            </div>
        </div>
    }
    else if (Model.RandomObjects != null && Model.RandomObjects.Any())
    {
        <h3>Your GenFu'd Data</h3>
        <table class="table">
            <thead>
                <tr>
                    @foreach (var property in Model.PropertyNames)
                    {
                        <th>@property</th>
                    }
                </tr>
            </thead>
            @foreach (var item in Model.RandomObjects)
            {
                <tr>
                    @foreach (var property in Model.PropertyNames)
                    {
                        <td>
                            @item[property]
                        </td>
                    }
                </tr>

            }
        </table>

        <form action="@Url.Action("Download")" class="form-horizontal" method="get">
            <div class="form-group">
                <button class="btn btn-success btn-lg pull-right" type="submit"><span class="glyphicon glyphicon-play"></span> Download as JSON</button>
            </div>
        </form>
    }
</div>
<span id="installation"></span>
<div class="row" >
    <h2>Installation</h2>
    <p>
        GenFu is available as a <a href="https://www.nuget.org/packages/GenFu/" target="_blank">NuGet package</a>.
        The easiest way to add GenFu to your .NET project is through Package Manager Console.
        Just type the following command:
    </p>
    <pre>Install-Package GenFu</pre>
    <h3>Or using the dotnet cli</h3>
                    <pre> dotnet add package GenFu</pre>
    <h3>No model, no problem.</h3>
    <p>
        Start your next project with a <a href="@Url.Action("Index","Wireframe")">Wireframe Prototype</a>.
    </p>
</div>
@section scripts{
<script type="text/javascript">

          var editor = CodeMirror.fromTextArea(document.getElementById("Source"), {
              lineNumbers: true,
              mode: "text/x-csharp"
          });
</script>
}